@section('title', "用户管理")
@section('content_title', '用户管理')
@section('content_title_small', isset($item) ? "编辑User Id: $item->id " : "增加")
@section('css')
    <link rel="stylesheet" href="{{ $assets_url}}/static/plugins/select2/select2.min.css">
    @endsection
    @section('content')
            <!-- Main content -->
    <section class="content" id="pjax-container">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-success">
                    <div class="box-body" style="display: block;">
                        <form method="POST" id="form" action="{{ url('/member') }}" class="form-horizontal"
                              accept-charset="UTF-8" pjax-container="">
                            <input type="hidden" name="id" value="{{ isSet($item['id']) ? $item['id'] : 0 }}">

                            <div class="box-body">
                                <div class="form-group">
                                    <label for="username" class="col-sm-2 control-label">帐号</label>

                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="username"
                                               value="{{ isSet($item->username)?$item->username:"" }}"
                                               placeholder="请使用手机号">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="nickname" class="col-sm-2 control-label">昵称</label>

                                    <div class="col-sm-10">

                                        <input type="text" class="form-control" name="nickname"
                                               value="{{ isSet($item->nickname)?$item->nickname:"" }}">

                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="roles" class="col-sm-2 control-label">权限</label>

                                    <div class="col-sm-10">
                                        @foreach($course as $c)
                                            <label class="radio-inline">
                                                @if(count($course) == 1)
                                                    <input type="checkbox" class="minimal" name="perms[]" value="{{$c->id}}"
                                                          checked>{{$c->name}}
                                                @else
                                                    <input type="checkbox" class="minimal" name="perms[]" value="{{$c->id}}"
                                                           @if(isSet($accessArr) && in_array($c->id,$accessArr)) checked @endif>{{$c->name}}
                                                @endif

                                            </label>
                                        @endforeach
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="mobile" class="col-sm-2 control-label">手机</label>

                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="mobile" name="mobile"
                                               value="{{ isSet($item['mobile']) ? $item['mobile'] : '' }}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="sex" class="col-sm-2 control-label">性别</label>

                                    <div class="col-sm-10">
                                        <label class="radio-inline">
                                            <input type="radio" name="sex" value="1" checked>男
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="sex"
                                                   value="2" {{ isset($item['sex']) && $item['sex'] == 2 ? 'checked' : '' }}>女
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="password" class="col-sm-2 control-label">密码</label>

                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="password"
                                               value="{{ isSet($item['password']) ? $item['password'] : '' }}">
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer">
                                <button type="button" class="btn btn-cancel pull-left"
                                        onclick="location='{{ url("/member") }}';">返回
                                </button>
                                <button type="submit" class="btn btn-info pull-right _submit_" data-form-id="form"
                                        data-refresh-url="{{ url("/member") }}">提交
                                </button>
                            </div>
                        </form>
                    </div><!-- /.box-body -->
                </div>
            </div>
        </div>
    </section>
@endsection
@section('js')
    <script src="{{ $assets_url }}/static/plugins/select2/select2.full.min.js"></script>
    <script src="{{ $assets_url }}/static/plugins/select2/i18n/zh-CN.js"></script>
    <script>
        $(function () {
            $('select').select2({
                placeholder: "角色",
                language: "zh-CN"
            });
        });
    </script>
@endsection
@extends('layouts.admin')